<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript" src="${ctx}/js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="${ctx}/js/ajaxupload_tx.3.6.js"></script>

<html>
<head>

</head>
<h1 class="page-title">添加员工资料详细信息</h1>

<body>
<div style="width:900px;height:500px">
    <label>
        照片 <span>*</span><br/>
        <img width="120" height="135" src="images/list_JS.jpg" id="image_uplad">

        <p id="a"></p>

        <p id="b"></p>

        <img width="120" height="135" src="images/list_JS.jpg" id="image_uplad2">
    </label>
</div>


<script type="text/javascript">
    $(function() {
        AjaxUpload.init('${ctx}/file/upload.xhtml', "image_uplad", "a", "b");
    });
    //文件名，扩展名
    function onUploadSubmit(file, ext) {
        //alert("file=" + file + ", ext=" + ext)
    }
    function onUploadComplete(file, response) {
        //{"message":"filePath","result":"F:\\Projects\\ehr\\src\\main\\webapp\\WEB-INF\\pages\\temp\\2012-06-26\\1340725945119_Qaga_1101134.jpg","success":true}
        alert("file=" + file + ":"+response)
        var d;
        try {
            d = eval("[" + response + "]");
        }
        catch(err) {
            alert("文件上传错误！");
            return;
        }
        
        //var message = d[0].message;
        //上传出错
        if (d[0].success == false) {
            alert("上传出错")
            return;
        }
        //上传成功
        else {
            $("#image_uplad2").attr("src", d[0].result)
            alert("上传成功")
        }
    }
</script>
</body>
</html>